#ifndef UPLOADHTTPPOOL_H__
#define UPLOADHTTPPOOL_H__

#include "HttpPool.h"
#include "UploadInterface.h"
class CUploadHttpPool : public CHttpPool//,public IUploadRecv
{
public:
	CUploadHttpPool();
	~CUploadHttpPool();

	bool AddUploadFile(IUploadRecv* pUR,const CString& strUrl,const CString& strAppCode,const CString& strUserId,const CString& strToken,const CString& strFileId,const CString& strFilePath);
	bool AddUploadFile(IUploadRecv* pUR,const CString& strUrl,const CString& strAppCode,const CString& strUserId,const CString& strToken,const CString& strFileId,const CString& strFilePath,LONGLONG nFileSize,LONGLONG nCurNum,LONGLONG nTotalNum,LONGLONG nSliceSize);
protected:
	CString MakeFormItem(const CString& strKey,const CString& strValue);
	CString MakeFormItem(const CString& strFilePath);

	bool AddUploadTask(IUploadRecv* pUR,const char * pBuf,int nLen,const CString& strHost,int nPort,const CString& strFilePath,LONGLONG nFileSize,const CString& strMimeTail,LONGLONG nCurNum,LONGLONG nTotalNum,LONGLONG nSliceSize);
	virtual void SendData(CWorkItem* );

	virtual void DoSetContentCoding(CWorkItem*,const string&);
	virtual void DoCallBack(CWorkItem*,char*,int);
	virtual void OnClose(CWorkItem*);
	virtual void OnSendData(CWorkItem*);
	virtual void Process();
	virtual void DoSetContentLength(CWorkItem*,int);
	virtual void DoSetContentRange(CWorkItem*,const string&){}

	bool GetFileSendBuf(UploadHttpTaskData *);
	bool GetFileSendOneBuf(UploadHttpTaskData *);
	int GetFileBuf(const CString& strFilePath,char* pBuf,int nLen,LONGLONG nOffSet);
	bool GetMimeTailBuf(UploadHttpTaskData *);

	virtual void OnUploadError(ErrorType);
	virtual void OnFileSend(UploadHttpTaskData *);

	virtual void OnSockClose(CWorkItem*);
private:
	//queue<UploadHttpTaskData*> m_qTaskDatas;
};

#endif